//
//  BanBu_selectPhotoCell.m
// Halfarea
//
//  Created by Wang Xj on 14-3-25.
//
//

#import "BanBu_selectPhotoCell.h"
@implementation BanBu_selectPhotoCell
@synthesize photoImgV = _photoImgV;
@synthesize photoinfo = _photoinfo;
@synthesize soundBu = _soundBu;
@synthesize playBu = _playBu;
@synthesize lineImg = _lineImg;
@synthesize player = _player;
@synthesize lenLa = _lenLa;

- (void)dealloc
{
    _lenLa = nil;
    _lineImg = nil;
    _playBu = nil;
    [_player release];
    _player = nil;
    _soundBu = nil;
    _photoinfo = nil;
    _photoImgV = nil;
    [super dealloc];
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        self.contentView.backgroundColor = [UIColor whiteColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        _photoImgV = [[UIImageView alloc]initWithFrame:CGRectMake(20, 10, 45, 45)];
        [_photoImgV.layer setBorderColor:[UIColorWithRGB(209, 209, 208, 1.0) CGColor]];
        [_photoImgV.layer setBorderWidth:1.0];
        [self.contentView addSubview:_photoImgV];
        [_photoImgV release];
        
        UIImageView * textFieldBack = [[UIImageView alloc]initWithFrame:CGRectMake(75, 17, 200, 30)];
        textFieldBack.image = [UIImage imageNamed:@"album_textField.png"];
        [self.contentView addSubview:textFieldBack];
        [textFieldBack release];
        
        _photoinfo = [[UITextField alloc]initWithFrame:CGRectMake(85, 21, 177, 20)];
        _photoinfo.backgroundColor = [UIColor clearColor];
        _photoinfo.text = @"";
        _photoinfo.font = [UIFont systemFontOfSize:13.0];
        _photoinfo.placeholder = NSLocalizedString(@"album_addDescribe", nil);
        [self.contentView addSubview:_photoinfo];
        [_photoinfo release];
        
        _soundBu = [UIButton buttonWithType:UIButtonTypeCustom];
        [_soundBu setFrame:CGRectMake(270.5, 5, 48, 56)];
        [_soundBu setImageEdgeInsets:UIEdgeInsetsMake(11.5, 10.0, 11.5, 5.0)];
        [_soundBu setImage:[UIImage imageNamed:@"album_soundBu.png"] forState:UIControlStateNormal];
        [self.contentView addSubview:_soundBu];
        
        _playBu = [UIButton buttonWithType:UIButtonTypeCustom];
        [_playBu setFrame:CGRectMake(5, 20, 74, 48.5)];
        [_playBu setImageEdgeInsets:UIEdgeInsetsMake(30, 15, 0.5, 15)];
        [_playBu setImage:[UIImage imageNamed:@"album_upPlay.png"] forState:UIControlStateNormal];
        [_playBu setImage:[UIImage imageNamed:@"album_stop.png"] forState:UIControlStateSelected];
        [_playBu addTarget:self action:@selector(playSoundintro) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:_playBu];
        _lenLa = [[UILabel alloc]initWithFrame:CGRectMake(41, 33, 20, 12)];
        _lenLa.backgroundColor = [UIColor clearColor];
        _lenLa.font = [UIFont systemFontOfSize:11.0];
        [_playBu addSubview:_lenLa];
        [_lenLa release];
        //        [_soundBu addTarget:self action:@selector(soundBuPressde) forControlEvents:UIControlEventTouchUpInside];
        _lineImg = [[UIImageView alloc]initWithFrame:CGRectZero];
        _lineImg.backgroundColor = UIColorWithRGB(188, 186, 193, 1.0);
        [self.contentView addSubview:_lineImg];
        [_lineImg release];
        _player = [[AVAudioPlayer alloc]init];
    }
    return self;
}

- (void)updateCellSoundData:(NSData *)soundData
{
    
}
/**
 * @函数名称：playSoundintro
 * @函数描述：播放已经录制的语音描述
 * @输入参数：void
 * @输出参数：void
 * @返回值：void
 * @author：yinlinlin
 */
- (void)playSoundintro
{
    if ([_playBu isSelected])
    {
        [_playBu setSelected:NO];
    }
    else
    {
        [_playBu setSelected:YES];
    }
    if (_playBuPressedCallBack)
    {
        _playBuPressedCallBack([_playBu isSelected]);
    }
//    AVAudioPlayer * _avPlayer = [[AVAudioPlayer alloc] initWithData:audioData error:&_error];
//    [_avPlayer prepareToPlay];
//    [_avPlayer setVolume:1.0];
}

- (void)awakeFromNib
{
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
